package rs.udd.web.controller;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import rs.udd.service.MailService;

@Controller
@RequestMapping({ "", "/", "/home", "/home/" })
public class HomeController {

	private static final Logger LOGGER = LogManager.getLogger(HomeController.class);

	@Autowired
	private MailService mailService;

	@RequestMapping(method = RequestMethod.GET)
	public String home() {
		LOGGER.info("HomeController.handleHomeGetRequest()");
		return "/home";
	}

	@RequestMapping(value = "/test-mail", method = RequestMethod.GET)
	public String testMail() {
		LOGGER.info("Testing mail...");
		mailService.sendMail("freestylernixx@gmail.com", "Test", "Test body");
		return "/home";
	}

}
